package com.seuic.hnjiningposapp.hnapps.ui.view.dialog;

import android.content.Context;
import android.widget.Button;
import android.widget.EditText;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ToastUtils;
import com.lxj.xpopup.core.BasePopupView;
import com.seuic.hnjiningposapp.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 输入身份证号和姓名
 */
public class InputIdNumNamePp extends BasePopupView {
    Unbinder bind;
    @BindView(R.id.input_idedtext)
    EditText inputIdedtext;
    @BindView(R.id.input_name_edtext)
    EditText inputNameEdtext;
    @BindView(R.id.next_btn)
    Button nextBtn;
    InputIdNumNameCallBack mInputIdNumNameCallBack;

    public InputIdNumNamePp(@NonNull Context context, InputIdNumNameCallBack inputIdNumNameCallBack) {
        super(context);
        this.mInputIdNumNameCallBack = inputIdNumNameCallBack;
    }

    @Override
    protected int getPopupLayoutId() {
        return R.layout.inputid_numnamepp;
    }

    @OnClick(R.id.next_btn)
    public void onViewClicked() {
        if (inputIdedtext.getText().toString().equals("")) {
            ToastUtils.showLong("请输入身份证号");
            return;
        }
        if (inputNameEdtext.getText().toString().equals("")) {
            ToastUtils.showLong("请输入姓名");
            return;
        }
        mInputIdNumNameCallBack.NumNameCallBack(inputNameEdtext.getText().toString(), inputIdedtext.getText().toString());
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        bind = ButterKnife.bind(this);

    }

    @Override
    protected void onDismiss() {
        super.onDismiss();
        //注解解绑
        if (bind != null && bind != Unbinder.EMPTY) {
            bind.unbind();
        }
        this.bind = null;
    }

    public interface InputIdNumNameCallBack {
        void NumNameCallBack(String username, String idnum);
    }
}
